package com.example.mvvmcore.retrofit;

import com.example.mvvmcore.retrofit.impl.FileProductImpl;
import com.example.mvvmcore.retrofit.impl.NetWorkProductImpl;

public class HttpFactory implements IFactroy{
    private static HttpFactory factory;

    public static HttpFactory getInstance(){
        if (factory==null) {
            factory = new HttpFactory();
        }
        return factory;
    }

    private NetWorkProductImpl netWorkProduct;
    private FileProductImpl fileProduct;

    @Override
    public IProduct factoryTyoe(ProductType type) {
        switch (type){
            default:
            case FILE:
                if (fileProduct==null) {
                    fileProduct = new FileProductImpl();
                }
                return fileProduct;
            case NETWORK:
                if (netWorkProduct==null) {
                    netWorkProduct = new NetWorkProductImpl();
                }
                return netWorkProduct;
        }
    }
}
